package com.zhonghui.controller;

import com.zhonghui.common.core.result.FwResult;
import com.zhonghui.model.Cart;
import com.zhonghui.service.CartService;
import com.zhonghui.service.config.AuthUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/cart")
public class CartController {

    @Autowired
    private CartService cartService;

    @GetMapping("/list")
    public FwResult get(){
        List<Cart> list = cartService.lambdaQuery().eq(Cart::getUserId,
                AuthUser.getUserId()).list();
        return FwResult.ok(list);
    }

}
